write: bin/main.bin
	@sudo python3 tools/stcflash bin/main.bin

bin/main.bin: temp/main.hex
	@hex2bin temp/main.hex
	@mv temp/main.bin bin/

temp/main.hex: temp/main.ihx
	@packihx temp/main.ihx > temp/main.hex

temp/main.ihx: temp/main.rel
	@sdcc temp/main.rel -o temp/main.ihx

temp/main.rel: src/main.c include/main.h
	@sdcc src/main.c -c -o temp/main.rel -I include

.PHONY: clean
clean:
	@rm -rf temp/*